<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html"
   template="../WEB-INF/templates/default.xhtml">
   <ui:define name="aside">
   <ui:include src="meny.xhtml" />
   </ui:define>
   <ui:define name="content">
      <h2>Azuriranje spiska studenata</h2>

      <h:form styleClass="loginForm">
         <h2>Dodavanje/izmena studenata</h2>
         <h:panelGrid columns="2" columnClasses="titleCell">
            <h:outputLabel for="idStud" value="ID:"/>
            <h:inputText id="idStud" value="#{nastavnikStudenti.newStudent.studentId}" readonly="true" />
            <h:outputLabel for="index" value="Br. indeksa:"/>
            <h:inputText id="index" value="#{nastavnikStudenti.newStudent.brojIndeksa}" />
            <h:outputLabel for="imeStud" value="Ime:"/>
            <h:inputText id="imeStud" value="#{nastavnikStudenti.newStudent.ime}" />
            <h:outputLabel for="prezimeStud" value="Prezime"/>
            <h:inputText id="prezimeStud" value="#{nastavnikStudenti.newStudent.prezime}" />
            <h:outputLabel for="godStud" value="God. upisa:"/>
            <h:inputText id="godStud" value="#{nastavnikStudenti.newStudent.godinaUpisa}" />
            <h:outputLabel for="userStud" value="Username:"/>
            <h:inputText id="userStud" value="#{nastavnikStudenti.newStudent.username}" />
            <h:outputLabel for="lozStud" value="Lozinka:"/>
            <h:inputText id="lozStud" value="#{nastavnikStudenti.newStudent.lozinka}" />
         </h:panelGrid>

         <p>
            <h:panelGrid columns="2">
               <h:commandButton id="register" action="#{nastavnikStudenti.addStudent()}" value="Sacuvaj" styleClass="saveButton"/>
               <h:commandButton id="cancelButton" action="#{nastavnikStudenti.initnewStudent()}" value="Odustani" styleClass="cancelButton"/>
               <h:messages styleClass="messages" errorClass="invalid" infoClass="valid" warnClass="warning"
                           globalOnly="true"/>  
            </h:panelGrid>
         </p>
      </h:form>
      <h2>Lista studenata</h2>
      <h:panelGroup rendered="#{empty nastavnikStudenti.studenti}">
         <em>Nema studenata.</em>
      </h:panelGroup>
      <h:dataTable id="tabelaStudenata" var="_student" value="#{nastavnikStudenti.studenti}" rendered="#{not empty nastavnikStudenti.studenti}" styleClass="simpletablestyle">
         <h:column>
            <f:facet name="header">Id</f:facet>
                #{_student.studentId}
         </h:column>
         <h:column>
            <f:facet name="header">Br. indeksa</f:facet>
                #{_student.brojIndeksa}
         </h:column>
         <h:column>
            <f:facet name="header">Ime</f:facet>
                #{_student.ime}
         </h:column>
         <h:column>
            <f:facet name="header">Prezime</f:facet>
                #{_student.prezime}
         </h:column>
         <h:column>
            <f:facet name="header">God. upisa</f:facet>
                #{_student.godinaUpisa}
         </h:column>
         <h:column>
            <f:facet name="header">Username</f:facet>
                #{_student.username}
         </h:column>
         <h:column>
            <f:facet name="header">Lozinka</f:facet>
                #{_student.lozinka}
         </h:column>
         <h:column>
            <f:facet name="header">Operacije</f:facet>
            <h:form>
            	<h:commandLink action="#{nastavnikStudenti.removeStudent(_student)}">obrisi</h:commandLink> &#160;&#160;&#160; <h:commandLink action="#{nastavnikStudenti.editStudent(_student)}">izmeni</h:commandLink>
            </h:form>
         </h:column>
      </h:dataTable>
   </ui:define>
</ui:composition>
